<script src="./jquery.min.js"></script>




var  url = decodeURI(location.href)
    
url=url.split('?')[1].split('=')[1]

console.log(url);
var box=document.querySelector('.box')
var brandtitleid=localStorage.getItem('brandtitleId')
console.log(brandtitleid)
let xhr2=new XMLHttpRequest()
xhr2.open('get',`http://chst.vip:1234/api/getbrandproductlist?brandtitleid=${brandtitleid}&pagesize=${4}`,true,)
xhr2.onload=function(){

   if(xhr2.status===200){
       var res2=JSON.parse(xhr2.responseText)
        console.log(res2.result)
   var lis2=''
   var n=1
   let regExp = /^<[^<]+\s+src="([^''""]*)"/;


   res2.result.forEach(function(so,ind){
   let tu = res2.result[ind].productImg.match(regExp)[1];
   console.log(tu)

       lis2+=`

      <li productid='${so.productId}'>
           <img src="${tu}">
           <div class="didi">
               <span class="hea">${so.productName}</span>
               <span>${so.productPrice}</span>
               <span>⭐⭐⭐⭐⭐</span>
               <span>${so.productQuote}</span>
               <span>${so.productCom}</span>
           </div>
       </li> 
            `
   })
   box.innerHTML=lis2


   $(function(){
   $('li').click(function(ev){
   var e=ev||event
 

   var target=e.target||e.srcElement
 
 
   if(target.nodeName==="IMG"){
       localStorage.setItem("productid",target.parentNode.getAttribute('productid'))
     location.href="./商品跳转详情页.html"

   }
 

})

})
   }
  
}

xhr2.send()

